package com.zmzncs.lmtc.module.shop.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.park.pojo.parkinfo.NearParkInfoVO;
import com.zmzncs.lmtc.module.park.pojo.parkinfo.ParkInfoDTO;
import com.zmzncs.lmtc.module.park.pojo.parkinfo.ParkInfoVO;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods.ShopGoodsDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods.ShopGoodsVO;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods_slide_show.ShopGoodsSlideShowDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods_slide_show.ShopGoodsSlideShowVO;
import com.zmzncs.lmtc.module.shop.pojo.shop_info.ShopInfoDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_info.ShopInfoVO;
import com.zmzncs.lmtc.module.shop.pojo.shop_ticket.ShopTicketDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_ticket.ShopTicketVO;
import com.zmzncs.lmtc.module.shop.service.ShopInfoService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商户-信息 前端控制器
 * </p>
 *
 * @author 高博文
 * @since 2021-05-20
 */
@RestController
@RequestMapping("/shop/shop-info")
public class ShopInfoController {

    @Autowired
    ShopInfoService shopInfoService;

    @ApiOperation(value = "附近商户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(paramType = "query", name = "latitude", value = "维度", required = true),
    })
    @GetMapping(value = "/getNearShopInfoList")
    public Rest<List<ShopInfoVO>> getNearShopInfoList(@NotBlank String longitude, @NotBlank String latitude){
        List<ShopInfoDTO>   shopInfoDTOS = shopInfoService.getNearShopInfoList(longitude,latitude);
        List<ShopInfoVO> shopInfoVOS = JsonUtil.listTransform(shopInfoDTOS, ShopInfoVO.class);
        return RestUtil.success(shopInfoVOS);
    }

    @ApiOperation(value = "商户的商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "shopInfoId", value = "商家Id", required = true),
    })
    @GetMapping(value = "/getShopGoodsListByShopInfo")
    public Rest<List<ShopGoodsVO>> getShopGoodsListByShopInfo(@NotBlank Long shopInfoId){
        List<ShopGoodsDTO>  shopGoodsDTOS = shopInfoService.getShopGoodsListByShopInfo(shopInfoId);
        List<ShopGoodsVO> shopGoodsVOS = JsonUtil.listTransform(shopGoodsDTOS, ShopGoodsVO.class);
        return RestUtil.success(shopGoodsVOS);
    }

    @ApiOperation(value = "商户的优惠券列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "shopInfoId", value = "商家Id", required = true),
    })
    @GetMapping(value = "/getShopTicketListByShopInfo")
    public Rest<List<ShopGoodsVO>> getShopTicketListByShopInfo(@RequestParam Long shopInfoId){
        List<ShopTicketDTO>  shopTicketDTOS = shopInfoService.getShopTicketListByShopInfo(shopInfoId);
        List<ShopTicketVO> shopTicketVO = JsonUtil.listTransform(shopTicketDTOS, ShopTicketVO.class);
        return RestUtil.success(shopTicketVO);
    }


    @ApiOperation(value = "附近商户的 商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(paramType = "query", name = "latitude", value = "维度", required = true),
    })
    @GetMapping(value = "/getNearShopGoodsList")
    public Rest<List<ShopGoodsVO>> getNearShopGoodsList(@NotBlank String longitude, @NotBlank String latitude){
        List<ShopGoodsDTO>  shopGoodsDTOS = shopInfoService.getNearShopGoodsList(longitude,latitude);
        List<ShopGoodsVO> shopGoodsVOS = JsonUtil.listTransform(shopGoodsDTOS, ShopGoodsVO.class);
        return RestUtil.success(shopGoodsVOS);
    }


    @ApiOperation(value = "附近商户 优惠券列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(paramType = "query", name = "latitude", value = "维度", required = true),
    })
    @GetMapping(value = "/getNearShopTicketList")
    public Rest<List<ShopTicketVO>> getNearShopTicketList(@NotBlank String longitude, @NotBlank String latitude){
        List<ShopTicketDTO>   shopTicketDTOS = shopInfoService.getNearShopTicketList(longitude,latitude);
        List<ShopTicketVO> shopTicketVOS = JsonUtil.listTransform(shopTicketDTOS, ShopTicketVO.class);
        return RestUtil.success(shopTicketVOS);
    }

    @ApiOperation(value = "附近，商户的轮播图列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(paramType = "query", name = "latitude", value = "维度", required = true),
    })
    @GetMapping(value = "/getNearShopGoodsSlideList")
    public Rest<List<ShopGoodsSlideShowVO>> getNearShopGoodsSlideList(@NotBlank String longitude, @NotBlank String latitude){
        List<ShopGoodsSlideShowDTO> shopGoodsSlideShowDTOS  = shopInfoService.getNearShopGoodsSlideList(longitude,latitude);
        List<ShopGoodsSlideShowVO> shopGoodsSlideShowVOS = JsonUtil.listTransform(shopGoodsSlideShowDTOS, ShopGoodsSlideShowVO.class);
        return RestUtil.success(shopGoodsSlideShowVOS);
    }


}

